//
//  ByGenderSelectView.m
//  recordworktool_ios
//
//  Created by mc on 2017/12/22.
//  Copyright © 2017年 ZhangZhanbin. All rights reserved.
//

#import "ByGenderSelectView.h"

@implementation ByGenderSelectView

- (id)init{
    self = [super init];
    if (self) {
        [self initViews];
    }
    return self;
}

- (void)initViews{
    // 设置弹出方式和位置
    self.positionMode = ZKBombPositionModeBottom;
    self.popMode = ZKBombPopModeBottom;
    
    // 自定义视图
    UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 120)];
    contentView.backgroundColor = [UIColor whiteColor];
    
    
    UILabel *line = [[UILabel alloc] init];
    [contentView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(contentView).offset(0);
        make.right.equalTo(contentView).offset(0);
        make.top.equalTo(contentView).offset(60);
        make.height.mas_equalTo(@1);
    }];
    line.backgroundColor = BY_LINE_COLOR;
    
    
    UILabel *maleLabel = [[UILabel alloc] init];
    [contentView addSubview:maleLabel];
    [maleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(contentView).offset(0);
        make.left.equalTo(contentView).offset(0);
        make.right.equalTo(contentView).offset(0);
        make.height.mas_equalTo(@60);
    }];
    maleLabel.textAlignment = NSTextAlignmentCenter;
    maleLabel.text = @"男";
    maleLabel.textColor = TEXT_COLOR;
    maleLabel.font = FONT(16);
    
    UILabel *femaleLabel = [[UILabel alloc] init];
    [contentView addSubview:femaleLabel];
    [femaleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(line.mas_bottom).offset(0);
        make.left.equalTo(contentView).offset(0);
        make.right.equalTo(contentView).offset(0);
        make.height.mas_equalTo(@59);
    }];
    femaleLabel.textAlignment = NSTextAlignmentCenter;
    femaleLabel.text = @"女";
    femaleLabel.textColor = TEXT_COLOR;
    femaleLabel.font = FONT(16);
    
    maleLabel.tag = 100;
    femaleLabel.tag = 200;
    UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
    [maleLabel addGestureRecognizer:tap1];
    
    UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
    [femaleLabel addGestureRecognizer:tap2];
    maleLabel.userInteractionEnabled = YES;
    femaleLabel.userInteractionEnabled = YES;
    
    self.contentView = contentView;
}

- (void)tapAction:(UITapGestureRecognizer *)tap{
    if (tap.view.tag == 100) {
        
        self.male();
        
    }else if (tap.view.tag == 200){
        
        self.female();
        
    }
    [self remove];
}

@end
